Page({
  data: {
    repairList: [],
    parmes: {
      current: 1,
      pageSize: 5,
    },
    isLoding: false,
  },
  onLoad() {
    this.getRepairList()
  },
  async getRepairList() {
    const { data, code } = await wx.http.get('/repair', this.data.parmes)
    if (code !== 10000) return wx.utils.toast('请求报修列表失败')
    // console.log(data.total)// 查看总条数
    this.data.parmes.current += 1
    if (this.data.repairList.length < data.total) {
      this.data.repairList.push(...data.rows)
      this.setData({
        repairList: this.data.repairList,
        isLoding: false,
      })
    } else {
      wx.utils.toast('没有更多数据了')
    }
  },
  // 上拉触底
  touchGround() {
    console.log(111)
    this.getRepairList()
  },
  // 下拉刷新
  refreshing() {
    this.setData({
      repairList: [],
      parmes: {
        current: 1,
        pageSize: 5,
      },
    })
    this.getRepairList()
  },
  goDetail(ev) {
    wx.navigateTo({
      url: '/repair_pkg/pages/detail/index?id=' + ev.mark.id,
    })
  },
  addRepair() {
    wx.navigateTo({
      url: '/repair_pkg/pages/form/index',
    })
  },
})
